'''
Created on 2010-8-5

@author: wangjo
'''
import os
import logging
from google.appengine.api import users
from google.appengine.ext import webapp
from google.appengine.ext.webapp import template

class TemplateSupportRequestHandler(webapp.RequestHandler):
    def generate(self, template_name, template_values = {}):
        values = {
            'request' : self.request,
            'user' :    users.get_current_user(),
            'is_admin': users.is_current_user_admin(),
            'login_url': users.create_login_url(self.request.uri),
            'logout_url': users.create_logout_url('http://%s/' % (self.request.host,)),
            'app_name' : 'Sodexo Finder',
        }
        values.update(template_values)
        dir = os.path.dirname(__file__)
        path = os.path.join(dir, os.path.join('templates', template_name)) 
        self.response.out.write(template.render(path, values))